#include <stdlib.h>
#include <stdio.h>

#include "mysql.h"

int main(int argc, char *argv[])
{
	/* 自定义一个连接句柄作为变量 */
	MYSQL my_connection;

	/* 使用非动态分配的连接结构 */
	mysql_init(&my_connection);

	if (mysql_real_connect(&my_connection, "localhost", "rick", "I do not know", "foo", 0, NULL, 0))
	{
		printf("Connection success\n");
		mysql_close(&my_connection);
	}
	else
	{
		fprintf(stderr, "Connectin failed\n");
		if (mysql_errno(&my_connection))
		{
			fprintf(stderr, "Connection  error %d: %s\n", mysql_errno(&my_connection), mysql_error(&my_connection));
		}
	}
	return EXIT_SUCCESS;
}	
